package com.gz.listener;

import javax.servlet.ServletRequest;
import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;

public class GzRequestListener implements ServletRequestListener {
    @Override
    public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
        System.out.println("GzRequestListener监听到 request对象被销毁");
    }

    @Override
    public void requestInitialized(ServletRequestEvent servletRequestEvent) {
        System.out.println("GzRequestListener监听到 request对象被创建");
        ServletRequest servletRequest = servletRequestEvent.getServletRequest();
        System.out.println("访问ip= "+servletRequest.getRemoteAddr());
        System.out.println("访问的资源= "+((HttpServletRequest)(servletRequest)).getRequestURL());
    }
}
